home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mrk2srch / mrk2srch.cb
C/C++ Source or Header  |  1990-02-01  |  843b  |  36 lines

  1. /*
  2.  * file: mrk2srch.cb
  3.  * copies marked pattern into extern string _s_pat
  4.  * which can be used for searches ( or search & replace )
  5.  */
  6.  
  7. extern string _s_pat;
  8. extern int _reg_exp;
  9.  
  10. string mrk2srch()
  11. {
  12.     int col0,row0,col1,row1;                // marked positions
  13.  
  14.     if( inq_marked( row0, col0, row1, col1 ) )
  15.     {
  16.         save_position();
  17.         _s_pat = "";
  18.         move_abs( row0, col0 );                // goto start of marked section
  19.         while( row0 != row1 )
  20.         {
  21.             _s_pat += read();                    // read to eol, append to _s_pat
  22.             move_abs( ++row0, 1 );            // goto beginning of next line
  23.         }
  24.         _s_pat += read( col1 - col0 +1 );// read marked part of line ending mark
  25.         restore_position();
  26.         _reg_exp = 1;                            // turn on regular expression search
  27.         message( "%s copied to _s_pat",_s_pat );
  28.         return( _s_pat );
  29.     }
  30.     else
  31.         error("Nothing is marked");
  32. }
  33.  
  34.         
  35.  
  36.